/*********************************************************************************************************/
* REGRESSIONS: HF Predictability 
/*********************************************************************************************************/

clear all
cls
set more off, permanently

/*********************************************************************************************************/

/* Here you should cd to your root directory and all other paths are then set relative to this  */
cd "/Users/etc/etc"

global dtas "../03_DTAs"
global temp "temp"


/*********************************************************************************************************/
/*********************************************************************************************************/

use $dtas/Regressions_Paper

/*********************************************************************************************************/
* Generate some dummies and regression related stuff. 
/*********************************************************************************************************/

describe

xtset date period 

gen Lag17_RSV = RSV[_n-17]
gen Lag16_RSV = RSV[_n-16]
gen Lag15_RSV = RSV[_n-15]
gen Lag14_RSV = RSV[_n-14]
gen Lag13_RSV = RSV[_n-13]
gen Lag12_RSV = RSV[_n-12]
gen Lag11_RSV = RSV[_n-11]
gen Lag10_RSV = RSV[_n-10]
gen Lag9_RSV = RSV[_n-9]
gen Lag8_RSV = RSV[_n-8]
gen Lag7_RSV = RSV[_n-7]
gen Lag6_RSV = RSV[_n-6]
gen Lag5_RSV = RSV[_n-5]
gen Lag4_RSV = RSV[_n-4]
gen Lag3_RSV = RSV[_n-3]
gen Lag2_RSV = RSV[_n-2]
gen Lag1_RSV = RSV[_n-1]

gen Lag1_hRSV = hRSV[_n-1]

/*********************************************************************************************************/

* REGRESSION: Rets on a constant 

est clear

foreach i in 1 2 3 4 5 6 7 8 9 10 11 12{
	
	qui: eststo: reg Rets if period==`i', rob cluster(month)
	estadd scalar R=100*(e(r2_a))
	estadd scalar Nobs=e(N)
	
}
	
/*********************************************************************************************************/

* REGRESSION: Rets on closing RSV

est clear

foreach i in 1 2 3 4 5 6 7 8 9 10 11 12{

	cap drop temp1
	gen temp1=Lag`i'_RSV
	
	qui: eststo: reg Rets temp1 if period==`i', rob cluster(month)
	estadd scalar R=100*(e(r2))
	estadd scalar Nobs=e(N)
	
}

esttab, nostar nonumbers mtitles("18-19" "19-20" "20-21" "21-22" "22-22" "23-24" "24-01" "01-02" "02-03" "03-04" "04-05" "05-06")   

/*********************************************************************************************************/

* REGRESSION: Rets on RSVs from last 3 hours of the day 


est clear

foreach i in 1 2 3 4 5 6 7 8 9 10 11 12{

	cap drop temp1
	cap drop temp2
	cap drop temp3
	
	local j=`i'+1
	local k=`i'+2
	
	gen temp1=Lag`i'_RSV
	gen temp2=Lag`j'_RSV
	gen temp3=Lag`k'_RSV
	
	qui: eststo: reg Rets temp1 temp2 temp3 if period==`i', rob cluster(month)
	estadd scalar R=100*(e(r2_a))
	estadd scalar Nobs=e(N)
	
	
}


esttab, nostar nonumbers mtitles("18-19" "19-20" "20-21" "21-22" "22-22" "23-24" "24-01" "01-02" "02-03" "03-04" "04-05" "05-06")   

/*********************************************************************************************************/

* REGRESSION: Rets on closing RSV plus positive dummy

est clear

foreach i in 1 2 3 4 5 6 7 8 9 10 11 12{

	cap drop temp1
	cap drop dum_neg
	cap drop temp2
	
	gen temp1=Lag`i'_RSV
	gen dum_neg = 0 
    replace dum_neg = 1 if temp1<0
	gen temp2=temp1*dum_neg
		
	qui: eststo: reg Rets temp1 dum_neg temp2 if period==`i', rob cluster(month)
	estadd scalar R=100*(e(r2))
	estadd scalar Nobs=e(N)
	
}

esttab, nostar nonumbers mtitles("18-19" "19-20" "20-21" "21-22" "22-22" "23-24" "24-01" "01-02" "02-03" "03-04" "04-05" "05-06")   


/*********************************************************************************************************/

* REGRESSION: VIX Interaction Regression  

est clear

foreach i in 1 2 3 4 5 6 7 8 9 10 11 12{

	cap drop temp1	
	cap drop temp2	
	cap drop temp3
	
	gen temp1=Lag`i'_RSV
	gen temp2=VIX
	gen temp3=temp2*temp1
	
	qui: eststo: reg Rets temp1 temp2 temp3 if period==`i', rob cluster(month)
	estadd scalar R=100*(e(r2_a))
	estadd scalar Nobs=e(N)
	
	
}


esttab, nostar nonumbers mtitles("18-19" "19-20" "20-21" "21-22" "22-22" "23-24" "24-01" "01-02" "02-03" "03-04" "04-05" "05-06")   
